package testing.module;

import java.awt.Graphics;
import java.util.Properties;

import utilities.display.shapes.definedshapes.DrawRectangle;
import utilities.module.Module;

/**
 * 
 * @author CoconutTank
 *
 */
public class Player extends Module
{
	/**
	 * 
	 */
	private static final long serialVersionUID = -2176035945896355681L;
	
	protected DrawRectangle box;

	protected int boxDX = 0;
	protected int boxDXAcc = 2;
	protected int boxDXDeacc = 1;
	protected int boxDXMax = 30;
	
	protected int boxDY = 0;
	protected int boxDYAcc = 2;
	protected int boxDYDeacc = 1;
	protected int boxDYMax = 30;
	
	protected boolean boxUp = false;
	protected boolean boxDown = false;
	protected boolean boxLeft = false;
	protected boolean boxRight = false;

	protected int minBoxX;
	protected int minBoxY;
	protected int maxBoxX;
	protected int maxBoxY;
	
	public Player()
	{
		minBoxX = 0;
		minBoxY = 0;
	}

	public void drawMe(Graphics g) 
	{	
	}

	public void update(Properties globals) 
	{
	}
	
	public void movement()
	{
		// Do acceleration here
		if(boxUp) boxDY -= boxDYAcc;
		if(boxDown) boxDY += boxDYAcc;
		if(boxLeft) boxDX -= boxDXAcc;
		if(boxRight) boxDX += boxDXAcc;
		
		// Do deceleration here
		if(!boxUp && boxDY < 0) boxDY += boxDYDeacc;
		if(!boxDown && boxDY > 0) boxDY -= boxDYDeacc;
		if(!boxLeft && boxDX < 0) boxDX += boxDXDeacc;
		if(!boxRight && boxDX > 0) boxDX -= boxDXDeacc;
		
		// Do max velocity checks here
		if(boxDX > boxDXMax) boxDX = boxDXMax;
		if(boxDX < -boxDXMax) boxDX = -boxDXMax;
		if(boxDY > boxDYMax) boxDY = boxDYMax;
		if(boxDY < -boxDYMax) boxDY = -boxDYMax;
		
		// Do actual movements here
		box.getShape().x += boxDX;
		box.getShape().y += boxDY;
		
		// Keep the box within the screen boundaries
		if(box.getShape().x < minBoxX) box.getShape().x = minBoxX;
		if(box.getShape().y < minBoxY) box.getShape().y = minBoxY;
		
		if(box.getShape().x >= maxBoxX) box.getShape().x = maxBoxX;
		if(box.getShape().y >= maxBoxY) box.getShape().y = maxBoxY;
	}
}
